package com.gosophia.accountManagement.action;

import java.net.URLEncoder;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.gosophia.commons.web.action.BaseSupportAction;
import com.gosophia.commons.web.logAnnotation.LogRecord;
import com.gosophia.userManagement.dto.UserAccountDTO;
import com.gosophia.userManagement.ws.UserManagementWebService;
import com.opensymphony.xwork2.ActionContext;


/**
 * 保存账号
 * @author mayue
 *
 */
@Controller("SaveUserAccountAction")
@Scope("prototype")
public class SaveUserAccountAction extends BaseSupportAction {

    private static final long serialVersionUID = 1L;
    
    @Autowired
    private UserManagementWebService userManagementWebService;
    
    private UserAccountDTO userAccountDTO;
    
    private List<Long> selectRoleIds;
    
    private String accountUser;

    @Override
    @LogRecord(eventAction="账号管理--新增账号",eventTarget="userAccountDTO")
    public String _execute() throws Exception {
        
        userManagementWebService.addUserAccount(userAccountDTO);
        //不出异常，认为成功
        super.getRequestResult().setMessage("账户"+userAccountDTO.getUserAccountName()+"保存成功");
        super.getRequestResult().setRsltCode("0");
        ActionContext.getContext().getSession().put("_lastOpResult", super.getRequestResult());

        return SUCCESS;
    }

    public UserAccountDTO getUserAccountDTO() {
        return userAccountDTO;
    }

    public void setUserAccountDTO(UserAccountDTO userAccountDTO) {
        this.userAccountDTO = userAccountDTO;
    }

    public List<Long> getSelectRoleIds() {
        return selectRoleIds;
    }

    public void setSelectRoleIds(List<Long> selectRoleIds) {
        this.selectRoleIds = selectRoleIds;
    }

    public String getAccountUser() {
        return accountUser;
    }

    public void setAccountUser(String accountUser) {
        this.accountUser = accountUser;
    }
    
}
